package pacman.entries.pacman.ml.destination_features;

import pacman.game.Game;
import pacman.game.Constants.DM;
import pacman.game.Constants.GHOST;

public class CanBeatGhostsDestinationFeature extends DestinationFeature {

	@Override
	public float EvaluateDestination(Game game, int destIndex) {
		
		int pacmanPosition = game.getPacmanCurrentNodeIndex();
		double pacmanDistance = game.getDistance(pacmanPosition, destIndex, DM.PATH);

		if (game.getDistance(game.getGhostCurrentNodeIndex(GHOST.BLINKY), 
				destIndex, game.getGhostLastMoveMade(GHOST.BLINKY), DM.PATH) < pacmanDistance)
			return 0.0f;
		if (game.getDistance(game.getGhostCurrentNodeIndex(GHOST.PINKY), 
				destIndex, game.getGhostLastMoveMade(GHOST.PINKY), DM.PATH) < pacmanDistance)
			return 0.0f;
		if (game.getDistance(game.getGhostCurrentNodeIndex(GHOST.INKY), 
				destIndex, game.getGhostLastMoveMade(GHOST.INKY), DM.PATH) < pacmanDistance)
			return 0.0f;
		if (game.getDistance(game.getGhostCurrentNodeIndex(GHOST.SUE), 
				destIndex, game.getGhostLastMoveMade(GHOST.SUE), DM.PATH) < pacmanDistance)
			return 0.0f;
		
		return 1.0f;
	}

}
